<template>
  <div>
    <a-upload  ref="uploadRef" :auto-upload="false" @change="onChange" draggable action="/" />
    <a-button type="primary" @click="submit">上传</a-button>
  </div>
</template>

<script setup lang="ts">
import type { FileItem } from '@arco-design/web-vue';
import useShardFileUpload from '@/hooks/useShardFileUpload';

const uploadRef = ref();
const files = ref<FileItem[]>([]);

const onChange = (fileList: FileItem[], fileItem: FileItem) => {
  files.value = fileList
}

const submit = async (e: any) => {
  e.stopPropagation();
  if (files.value.length === 0) {
    return;
  }
  // 拿到所有的分片结果
  useShardFileUpload(files.value[0].file, (fileChunks: any) => {
    console.log(fileChunks)
  });
};
</script>

<style lang="less" scoped>

</style>